import { axios, postJson, putJson } from '@/utils/request';
import api from '@/api/index';

/**
 * 添加菜单信息
 * @param parameter
 */
export function addMenu (parameter) {
  return postJson(api.Menu, parameter, 1)
}

/**
 * 更新菜单信息
 * @param parameter
 */
export function updateMenu (parameter) {
  return putJson(api.Menu, parameter, 1)
}

/**
 * 移除菜单信息
 * @param id
 */
export function delMenuById (id) {
  return axios({
    url: `${api.Menu}/` + id,
    method: 'delete',
    params: {}
  })
}

export function customUserPermission(userId, addPermissions, reducePermissions) {
  return putJson(`${api.Menu}/user/permission/${userId}`, { addPermissions: addPermissions, reducePermissions: reducePermissions }, 1)
}

/**
 * 添加角色权限
 * @param roleId
 */
export function customRolePermission (roleId, menuIds) {
  return putJson(`${api.Menu}/role/permission/${roleId}`, menuIds, 1);
}
